<?php

class Position Extends MY_Controller
{

	public function view()
	{
		$this->load->model('m_position','mp');
		$this->load->library('pagination');
		
		$config['base_url'] = base_url().'position/view';
		$config['total_rows'] = $this->mp->count_data();
		$config['per_page'] = 10; 
		
		//Pagnate Design start
			$config['full_tag_open'] = '<div class="pagination pagination-centered"><ul>';
			$config['full_tag_close'] = '</ul></div>';
			
			$config['num_tag_open'] = '<li>';
			$config['num_tag_close'] = '</li>';
			
			$config['cur_tag_open'] = '<li class="active"><a href="#">';
			$config['cur_tag_close'] = '</a></li>';
			
			$config['prev_link'] = '&lt;';
			$config['prev_tag_open'] = '<li>';
			$config['prev_tag_close'] = '</li>';
			
			$config['next_link'] = '&gt;';
			$config['next_tag_open'] = '<li>';
			$config['next_tag_close'] = '</li>';
			
			$config['first_link'] = 'First';
			$config['first_tag_open'] = '<li>';
			$config['first_tag_close'] = '</li>';
			
			$config['last_link'] = 'Last';
			$config['last_tag_open'] = '<li>';
			$config['last_tag_close'] = '</li>';
			
		//Pagnate Design end
		
		$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
		$this->pagination->initialize($config); 
		$this->view_data['positions'] = $this->mp->fetch_positions($config['per_page'] ,$page);
		$this->view_data['pagnate_links'] = $this->pagination->create_links();
	
	}
	
	public function add()
	{
		$this->load->library('form_validation');
		$this->view_data['system_message'] = $this->_msg();
		
		if($this->input->post('add_position'))
		{
			$this->form_validation->set_rules('name','Name of position','requried|trim"htmlspecialchars');
			$this->form_validation->set_rules('description','Description','trim"htmlspecialchars');
			
			$this->load->model('m_position','mp');
			if($this->mp->insert($this->input->post()))
			{
				$this->_msg('s','New Position Was successfully added','position/add');
			}else{
				$this->view_data['system_message'] = $this->_msg('e','An error was encountered while adding a new position');
			}
		
		
		}
	
	}
	
	public function update()
	{
	
	
	
	}
	
	public function delete()
	{
	
	}













}